package com.clement.spring.study;

import com.clement.spring.study.model.Person;
import com.clement.spring.study.model.PersonForm;
import com.clement.spring.study.repository.BookDao;
import com.clement.spring.study.service.EmailService;
import com.clement.spring.study.service.PersonFormValidatorAssertService;
import org.junit.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.MessageSource;

/**
 * Created by Clement on 2017/2/27.
 */
@SpringBootApplication
public class ApplicationRunner implements CommandLineRunner {

    @Autowired
    private MessageSource messageSource;
    @Autowired
    private BookDao bookDao;
    @Autowired
    private EmailService emailService;
    @Autowired
    private Person person;
    @Autowired
    private PersonFormValidatorAssertService service;
    public static void main(String[] args) {
        SpringApplication.run(ApplicationRunner.class, args);
    }

    @Override
    public void run(String... strings) throws Exception {
            Assert.assertNotNull(service.getValidator());
//        PersonForm personForm = new PersonForm("sd",-1);
//        Assert.assertNotNull(emailService.getPublisher()); //test the publisher is autowired
//        emailService.sendEmail("known.spammer@example.com","black");
//        String message = messageSource.getMessage("message", null, "hello world", null);
//        bookDao.getBookById("1");
//        System.out.println(person);
    }
}
